package 笔试记录.M10day27;

import java.util.ArrayList;
import java.util.Comparator;

public class Main2 {
    public String largestNumber (int[] nums) {
        // write code here
        String s;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            list.add(nums[i]);
        }
        list.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                if((o1.toString() + o2.toString()).compareTo(o2.toString() + o1.toString()) > 0){
                    return 1;
                }
                return -1;
            }
        });
        s = "";
        int index = list.size() - 1;
        while(!list.isEmpty()){
            s = s + list.remove(index);
            index--;
        }
        return s;
    }
}
